const gulp = require("gulp");
const connect = require("gulp-connect");

gulp.task("html", (done) => {
  gulp.src("*.html").pipe(gulp.dest("dist")).pipe(connect.reload());
  done();
});
gulp.task("css", (done) => {
  gulp.src("css/**").pipe(gulp.dest("dist/css")).pipe(connect.reload());
  done();
});
gulp.task("js", (done) => {
  gulp.src("js/**").pipe(gulp.dest("dist/js")).pipe(connect.reload());
  done();
});
//监听
gulp.task("watch", (done) => {
  gulp.watch("*.html", gulp.series("html"));
  gulp.watch("css/**", gulp.series("css"));
  gulp.watch("js/**", gulp.series("js"));
  done();
});
//本地服务器
gulp.task("server", (done) => {
  connect.server({
    root: "dist",
    livereload: true,
  });
  done();
});
gulp.task("default", gulp.series("server", "watch"));
